package com.binguo.checker;

import com.binguo.common.exception.ServiceException;
import com.binguo.model.repository.ShopRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import static com.binguo.common.exception.ErrorCode.SHOP_NOT_EXISTS;

/**
 * Created by haibang on 18/5/21.
 */
@Component
public class ShopChecker {

    @Autowired
    ShopRepository shopRepository;


    public void checkNotExist(Integer shopId){
        if(shopRepository.findById(shopId)==null) throw new ServiceException(SHOP_NOT_EXISTS);
    }
}
